var Response = require('nitro/response').Response;
var users = require('google/appengine/api/users');

exports.GET = function(req) {
  var cmdID = req.pathInfo || "/Logout:20100901T173210";
  var logoutURL = users.createLogoutURL('/apis/auth/check' + cmdID);
  return Response.redirect(logoutURL);
};

exports.POST = function(req) {
  var params = JSON.parse(req.input.read().decodeToString("utf-8"));
  
  var cmdID = params.commandID.replace(':', '_sep_');
  
  var logoutRedirect = '/apis/auth/check/' + params.commandID;
  var logoutURL = users.createLogoutURL(logoutRedirect);
  return Response.redirect(logoutURL);
};